<%@page import="org.proddevplm.dao.data.Project"%>
<%@page import="org.proddevplm.dao.data.Roles"%>
<%@page import="org.proddevplm.dao.data.RelationMatrix"%>
<%@page import="java.util.List"%>
<%@page import="org.proddevplm.constants.UserConstants"%>
<%@page import="org.proddevplm.dao.data.User"%>
<script>
	$(function() {
		$( "#toolsAccordion" ).accordion({
			fillSpace: false,
			autoHeight: false,
			navigation: true,
			collapsible: true
		});
	});
			
	$(function() {
		$( "#radio" ).buttonset();
	});
	
	$(function(){
		$( "button" ).button();
	})

	function loadPage(page){
		$("#toolPage").load(page);
	}
	
	function loadPageWithReq(request, page) {
        $.post(request, function(data) {
            $("#toolPage").load(page);
        });
    }
	
	function ahpPage(){
		loadPage("content/project/devTools/workspace/prioritization/ahpPage.jsp");
	}
	
	function caPage(){
		loadPageWithReq("/proddev/controller?manager=dataAccessManager&method=0", "content/project/devTools/workspace/competitors/caPage.jsp");
	}
	
	function swotPage(){
		loadPageWithReq("/proddev/controller?manager=dataAccessManager&method=1", "content/project/devTools/workspace/competitors/swotPage.jsp");
	}
	
	function shPage(){
		loadPage("content/project/devTools/workspace/stakeholders/shIdentification.jsp");
	}
	
	function nrPage(userType){
		if (userType == "Project Manager") {
			loadPage("content/project/devTools/workspace/needReqs/nrSorting.jsp");
		}
		else if (userType == "intern"){
			loadPageWithReq("/proddev/controller?manager=dataAccessManager&method=7", "content/project/devTools/workspace/needReqs/nrGathering.jsp")
		}
		else loadPageWithReq("/proddev/controller?manager=dataAccessManager&method=8", "content/project/devTools/workspace/needReqs/nrGathering.jsp")
	}
	
	function mmPage(){
		loadPage("content/project/devTools/workspace/creativity/mmPage.jsp");
	}
	
	function voctPage(){
		loadPageWithReq("/proddev/controller?manager=dataAccessManager&method=17", "content/project/devTools/workspace/needReqs/voctPage.jsp");
	}
	
	function bsPage(){
		loadPage("content/project/devTools/workspace/creativity/bsPage.jsp");
	}
	
	function functionsPage(){
		loadPageWithReq("/proddev/controller?manager=dataAccessManager&method=18", "content/project/devTools/workspace/functions/functionIdentification.jsp");
	}

	function pughPage(){
		loadPage("content/project/devTools/workspace/concepts/conceptSelection.jsp");
	}
	
	function lcsPage(){
		loadPage("content/project/devTools/workspace/lifeCycleStrategy/lifeCycleStrategies.jsp");
	}
	
	function dfXPage(){
		loadPage("content/project/devTools/workspace/dfX/designForX.jsp");
	}
	
	function correlationMatrixPage(){
		loadPage("content/project/devTools/workspace/correlations/correlationMatrix.jsp");
	}
	
	function ctqPage(){
		loadPageWithReq("/proddev/controller?manager=dataAccessManager&method=19", "content/project/devTools/workspace/cTQs/technicalChars.jsp");
	}
	
	function designElementsPage(){
		loadPageWithReq("/proddev/controller?manager=dataAccessManager&method=20", "content/project/devTools/workspace/designElements/designElementsDefinition.jsp");
	}
	
	function resourcesPage(){
		loadPage("content/project/devTools/workspace/resources/addResource.jsp");
	}
	
	function modelAnalysisPage(){
		loadPage("content/project/devTools/workspace/modelAnalysis/modelAnalysis.jsp");
	}
	
	function lcEvaluationPage(){
		loadPage("content/project/devTools/workspace/lcEvaluation/lifeCycleEvaluation.jsp");
	}
	
	function changeReportPage(){
		loadPage("content/project/devTools/workspace/changes/changeReport.jsp");
	}
	
	function validationPage(){
		loadPage("content/project/devTools/workspace/validation/validationMethodology.jsp");
	}

</script>
<%

	String currentRole = "";
	User user = (User)session.getAttribute(UserConstants.USER);
	List relMatrixUser = (List)session.getAttribute("relMatrixUser");
	int projectId = (Integer)session.getAttribute("projectId");
	for (int index=0; index<relMatrixUser.size(); index++){
		RelationMatrix rm = (RelationMatrix)relMatrixUser.get(index);
		Project userProject = rm.getProject();
		if(userProject.getId()==projectId){
			Roles userRole = rm.getRole();
			currentRole = userRole.getRole();
		}
	}
	
	String userType = user.getType();
	
	if (userType.equals("intern")){
		if (currentRole.equals("Project Manager")){
			userType="Project Manager";
			}
	}
	
%>

<div id="toolsAccordion">
	<div style="padding-left:5px;"><a href="#"><b>Analysis Stage</b></a></div>

	<div id="analysisButtons" style="font-size:x-small;" align="center">
		<div style="width:100%;">
			<button id="caButton" name="caButton" onclick="caPage()" style="width:195px">Competitors Analysis</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="swotButton" name="swotButton" onclick="swotPage()" style="width:195px">SWOT Analysis</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="shButton" name="shButton" onclick="shPage()" style="width:195px">Stakeholders' Identification</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="nrButton" name="nrButton" onclick="nrPage('<%=userType%>')" style="width:195px">Needs & Requirements</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="ahpButton" name="ahpButton" onclick="ahpPage()" style="width:195px">Create hierarchy</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			
			<button id="voctButton" name="voctButton" onclick="voctPage()" style="width:195px">Voice of Customer Table</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="bsButton" name="bsButton" onclick="bsPage()" style="width:195px">Brainstorming</button>
		</div>
		
		
			
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Design Constraints</b></a></div>
	
	<div id="constraintsButtons" style="font-size:x-small;" align="center">
		<div style="width:100%;">
			<button id="functionsButton" name="functionsButton" onclick="functionsPage()" style="width:195px">Functions identification</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="pughButton" name="pughButton" onclick="pughPage()" style="width:195px">Concept selection</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="lcsButton" name="lcsButton" onclick="lcsPage()" style="width:195px">Life cycle strategies</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="dfXButton" name="dfXButton" onclick="dfXPage()" style="width:195px">Design for X identification</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="correlationMatrixButton" name="correlationMatrixButton" onclick="correlationMatrixPage()" style="width:195px">Correlation Matrix</button>
		</div>
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Product Planning</b></a></div>
	
	<div id="planningButtons" style="font-size:x-small;" align="center">
		<div style="width:100%;">
			<button id="ctqButton" name="ctqButton" onclick="ctqPage()" style="width:195px">Technical characteristics</button>
		</div>
		
		<div style="margin-top:5px; width:100%;">
			<button id="designElementsButton" name="designElementsButton" onclick="designElementsPage()" style="width:195px">Design Elements identification</button>
		</div>
		
		<div style="margin-top:5px; width:100%">
			<button id="correlationMatrixButton" name="correlationMatrixButton" onclick="correlationMatrixPage()" style="width:195px">Correlation Matrix</button>
		</div>		
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Concept Development</b></a></div>
	
	<div id="developmentButtons" style="font-size:x-small;" align="center">
		<div style="width:100%;">
			<button id="resourcesButton" name="resourcesButton" onclick="resourcesPage()" style="width:195px">Add resource file</button>
		</div>
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Concept Enhancement</b></a></div>
	
	<div id="enhancementButtons" style="font-size:x-small;" align="center">
		<div style="width:100%;">
			<button id="modelAnalysisButton" name="modelAnalysisButton" onclick="modelAnalysisPage()" style="width:195px">Model Analysis</button>
		</div>
		
		<div style="margin-top:5px; width:100%;">
			<button id="lcEvaluationButton" name="lcEvaluationButton" onclick="lcEvaluationPage()" style="width:195px">Life Cycle Evaluation</button>
		</div>
		
		<div style="margin-top:5px; width:100%;">
			<button id="changeReportButton" name="changeReportButton" onclick="changeReportPage()" style="width:195px">Modifications proposals</button>
		</div>
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Validation</b></a></div>
	
	<div id="validationButtons" style="font-size:x-small;" align="center">
		<div style="width:100%;">
			<button id="validationButton" name="validationButton" onclick="validationPage()" style="width:195px">Validation Methodology</button>
		</div>
		
		<div style="margin-top:5px; width:100%;">
			<button id="changeReportButton" name="changeReportButton" onclick="changeReportPage()" style="width:195px">Modifications proposals</button>
		</div>
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Production Phase</b></a></div>
	<div>
		Production tools
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Use Phase</b></a></div>
	<div>
		Use phase tools
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Support Phase</b></a></div>
	<div>
		Support phase tools
	</div>
	
	<div style="padding-left:5px;"><a href="#"><b>Retirement Phase</b></a></div>
	<div>
		Retirement phase tools
	</div>
	
</div>